#pragma once

#include "ModelessDialog.h"


// PositionDlg dialog

class PositionDlg : public CModelessDialog, public L_Observer
{
	DECLARE_DYNAMIC(PositionDlg)

public:

	enum POS_DISP_TYPE {
		ALL_POS,
		OPEN_POS,
		LONG_POS,
		SHORT_POS
	};

	PositionDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~PositionDlg();

	virtual BOOL Create(CWnd *pParentWnd = CWnd::FromHandle(L_GetMainWnd()));

// Dialog Data
	enum { IDD = IDD_POSITIONDLG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()

protected:
// L_Observer
	virtual void HandleMessage(L_Message const *pMsg);

private:
	//Ctrls
	CListCtrl m_PosDataListCtrl;
	CComboBox m_PosCombo;

	//Ctrl Helpers
	void ResizeControls();
	void UpdatePosCombo();
	void UpdateComboBox(CComboBox &cBox, position_iterator itStart, position_iterator itEnd);
	void FindPosition(CComboBox &cBox);
	void InitializeDataCtrlRows();
	CString GetTextForFunction(int function);
	void UpdatePositionChangePositionData(); //values that change on positionchange msgs
	void UpdateOrderChangePositionData(); //values that change on orderchange msgs
	void UpdateStaticPositionData();
	void OnViewOrders();
	void OnViewExecutions();

	char APIFunctions[64][32];
	void SetAPIFunctions();
	
	//API Objects
	L_Account *account;
	L_Position *position;

	int m_PosDispType;

public:
	virtual BOOL OnInitDialog();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnCbnSelchangePosCombo();
	afx_msg void OnShowOrders();
	afx_msg void OnShowExecutions();
	afx_msg void OnBnClickedAllRadio();
	afx_msg void OnBnClickedOpenRadio();
	afx_msg void OnBnClickedLongRadio();
	afx_msg void OnBnClickedShortRadio();
};
